<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.9.1"/>
<title>IDA SDK: Segment translations</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">IDA SDK
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.9.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="files.html"><span>Header&#160;Files</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Segment translations<div class="ingroups"><a class="el" href="group__seg.html">Segments</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Used to represent overlayed memory banks. </p>
<p>Segment translations are used to redirect access to overlayed segments so that the correct overlay is accessed. Each segment has its own translation list. For example, suppose we have four segments: </p><pre>
    A               1000-2000
    B               1000-2000
      C             2000-3000
      D             2000-3000
  </pre><p> A and B occupy the same virtual addresses. The same with C and D. Segment A works with segment C, segment B works with segment D.</p>
<p>So all references from A to 2000-3000 should go to C. For this we add translation C for segment A. The same with B,D: add translation D for segment B. Also, we need to specify the correct segment to be accessed from C, thus we add translation A for segment C. And we add translation B for segment D.</p>
<p>After this, all references to virtual addresses 2000-3000 made from A go to segment C (even if segment A would be large and occupy 1000-3000) So, we need the following translations: </p><pre>
    A:      C
    B:      D
    C:      A
    D:      B
 </pre><p> With translations, the segments may reside at any linear addresses, all references will pass through the translation mechanism and go to the correct segment.</p>
<p>Segment translation works only for code segments (see <a class="el" href="ua_8hpp.html#a1ef618838a811385a5f2564bcab4e762" title="Map a code address. ">map_code_ea()</a>) </p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ga3337a43b347cedb01c040f78cd68a6bf"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga3337a43b347cedb01c040f78cd68a6bf"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__seg__trans.html#ga3337a43b347cedb01c040f78cd68a6bf">MAX_SEGM_TRANSLATIONS</a>&#160;&#160;&#160;64</td></tr>
<tr class="memdesc:ga3337a43b347cedb01c040f78cd68a6bf"><td class="mdescLeft">&#160;</td><td class="mdescRight">max number of segment translations <br /></td></tr>
<tr class="separator:ga3337a43b347cedb01c040f78cd68a6bf"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga162acfa28de46b3afb2aba0639f7f0a8"><td class="memItemLeft" align="right" valign="top"><a class="el" href="pro_8h.html#a8ddba56b40c4be92718f8059abf51147">idaman</a> bool <a class="el" href="pro_8h.html#a176294e75f953787714b9d08ffa89adf">ida_export</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__seg__trans.html#ga162acfa28de46b3afb2aba0639f7f0a8">add_segment_translation</a> (<a class="el" href="pro_8h.html#a7b0aeaed04e477c02cf8ea3452002d1a">ea_t</a> segstart, <a class="el" href="pro_8h.html#a7b0aeaed04e477c02cf8ea3452002d1a">ea_t</a> mappedseg)</td></tr>
<tr class="memdesc:ga162acfa28de46b3afb2aba0639f7f0a8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Add segment translation.  <a href="#ga162acfa28de46b3afb2aba0639f7f0a8">More...</a><br /></td></tr>
<tr class="separator:ga162acfa28de46b3afb2aba0639f7f0a8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga77b4d9ab9a809f3ae2e12ea7ef285576"><td class="memItemLeft" align="right" valign="top"><a class="el" href="pro_8h.html#a8ddba56b40c4be92718f8059abf51147">idaman</a> bool <a class="el" href="pro_8h.html#a176294e75f953787714b9d08ffa89adf">ida_export</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__seg__trans.html#ga77b4d9ab9a809f3ae2e12ea7ef285576">set_segment_translations</a> (<a class="el" href="pro_8h.html#a7b0aeaed04e477c02cf8ea3452002d1a">ea_t</a> segstart, const <a class="el" href="pro_8h.html#a9f46d9d52bbfcc78bc1836f4f2683da4">eavec_t</a> &amp;transmap)</td></tr>
<tr class="memdesc:ga77b4d9ab9a809f3ae2e12ea7ef285576"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set new translation list.  <a href="#ga77b4d9ab9a809f3ae2e12ea7ef285576">More...</a><br /></td></tr>
<tr class="separator:ga77b4d9ab9a809f3ae2e12ea7ef285576"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga18d43bfa417e11caee34c45ff3ca5288"><td class="memItemLeft" align="right" valign="top"><a class="el" href="pro_8h.html#a8ddba56b40c4be92718f8059abf51147">idaman</a> void <a class="el" href="pro_8h.html#a176294e75f953787714b9d08ffa89adf">ida_export</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__seg__trans.html#ga18d43bfa417e11caee34c45ff3ca5288">del_segment_translations</a> (<a class="el" href="pro_8h.html#a7b0aeaed04e477c02cf8ea3452002d1a">ea_t</a> segstart)</td></tr>
<tr class="memdesc:ga18d43bfa417e11caee34c45ff3ca5288"><td class="mdescLeft">&#160;</td><td class="mdescRight">Delete the translation list.  <a href="#ga18d43bfa417e11caee34c45ff3ca5288">More...</a><br /></td></tr>
<tr class="separator:ga18d43bfa417e11caee34c45ff3ca5288"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga546786583c25f26b1477f83df2d35fa2"><td class="memItemLeft" align="right" valign="top"><a class="el" href="pro_8h.html#a8ddba56b40c4be92718f8059abf51147">idaman</a> <a class="el" href="pro_8h.html#ab65ed42d67e6c517c746ff2a6a187016">ssize_t</a> <a class="el" href="pro_8h.html#a176294e75f953787714b9d08ffa89adf">ida_export</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__seg__trans.html#ga546786583c25f26b1477f83df2d35fa2">get_segment_translations</a> (<a class="el" href="pro_8h.html#a9f46d9d52bbfcc78bc1836f4f2683da4">eavec_t</a> *transmap, <a class="el" href="pro_8h.html#a7b0aeaed04e477c02cf8ea3452002d1a">ea_t</a> segstart)</td></tr>
<tr class="memdesc:ga546786583c25f26b1477f83df2d35fa2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get segment translation list.  <a href="#ga546786583c25f26b1477f83df2d35fa2">More...</a><br /></td></tr>
<tr class="separator:ga546786583c25f26b1477f83df2d35fa2"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ga162acfa28de46b3afb2aba0639f7f0a8"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="pro_8h.html#a8ddba56b40c4be92718f8059abf51147">idaman</a> bool <a class="el" href="pro_8h.html#a176294e75f953787714b9d08ffa89adf">ida_export</a> add_segment_translation </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pro_8h.html#a7b0aeaed04e477c02cf8ea3452002d1a">ea_t</a>&#160;</td>
          <td class="paramname"><em>segstart</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="pro_8h.html#a7b0aeaed04e477c02cf8ea3452002d1a">ea_t</a>&#160;</td>
          <td class="paramname"><em>mappedseg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Add segment translation. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">segstart</td><td>start address of the segment to add translation to </td></tr>
    <tr><td class="paramname">mappedseg</td><td>start address of the overlayed segment </td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">1</td><td>ok </td></tr>
    <tr><td class="paramname">0</td><td>too many translations or bad segstart </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga77b4d9ab9a809f3ae2e12ea7ef285576"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="pro_8h.html#a8ddba56b40c4be92718f8059abf51147">idaman</a> bool <a class="el" href="pro_8h.html#a176294e75f953787714b9d08ffa89adf">ida_export</a> set_segment_translations </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pro_8h.html#a7b0aeaed04e477c02cf8ea3452002d1a">ea_t</a>&#160;</td>
          <td class="paramname"><em>segstart</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="pro_8h.html#a9f46d9d52bbfcc78bc1836f4f2683da4">eavec_t</a> &amp;&#160;</td>
          <td class="paramname"><em>transmap</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Set new translation list. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">segstart</td><td>start address of the segment to add translation to </td></tr>
    <tr><td class="paramname">transmap</td><td>vector of segment start addresses for the translation list. If transmap is empty, the translation list is deleted. </td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">1</td><td>ok </td></tr>
    <tr><td class="paramname">0</td><td>too many translations or bad segstart </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga18d43bfa417e11caee34c45ff3ca5288"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="pro_8h.html#a8ddba56b40c4be92718f8059abf51147">idaman</a> void <a class="el" href="pro_8h.html#a176294e75f953787714b9d08ffa89adf">ida_export</a> del_segment_translations </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pro_8h.html#a7b0aeaed04e477c02cf8ea3452002d1a">ea_t</a>&#160;</td>
          <td class="paramname"><em>segstart</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Delete the translation list. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">segstart</td><td>start address of the segment to delete translation list </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga546786583c25f26b1477f83df2d35fa2"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="pro_8h.html#a8ddba56b40c4be92718f8059abf51147">idaman</a> <a class="el" href="pro_8h.html#ab65ed42d67e6c517c746ff2a6a187016">ssize_t</a> <a class="el" href="pro_8h.html#a176294e75f953787714b9d08ffa89adf">ida_export</a> get_segment_translations </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="pro_8h.html#a9f46d9d52bbfcc78bc1836f4f2683da4">eavec_t</a> *&#160;</td>
          <td class="paramname"><em>transmap</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="pro_8h.html#a7b0aeaed04e477c02cf8ea3452002d1a">ea_t</a>&#160;</td>
          <td class="paramname"><em>segstart</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get segment translation list. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">transmap</td><td>vector of segment start addresses for the translation list </td></tr>
    <tr><td class="paramname">segstart</td><td>start address of the segment to get information about </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>-1 if no translation list or bad segstart. otherwise returns size of translation list. </dd></dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.9.1
</small></address>
</body>
</html>
